home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1998 March / Software of the Month Club 1998 March.iso / pc / win / biz / shopwiz / _setup.1 / configure < prev    next >
Text File  |  1997-12-07  |  4KB  |  116 lines

  1. #!/usr/bin/perl
  2.  
  3. $debug = 1;
  4. $pgplocation = " ";
  5. $pgppathlocation = " ";
  6.  
  7. print "Configuring...\n";
  8.  
  9. $maillocation = `whereis sendmail`;
  10. $maillocation =~ s/^sendmail://;
  11. $maillocation =~ s/\S+\.\S+//g;
  12.  
  13. @maillocation = split(/\s+/, $maillocation);
  14.  
  15. if (!@maillocation) {
  16.     print "Can't find sendmail. Aborting.\n";
  17.     exit;
  18. } elsif (scalar(@maillocation) == 1) {
  19.     $sendmail = $maillocation[0];
  20. } else {
  21.     print "I found more than one instance of sendmail:\n";
  22.     foreach $thing (@maillocation) {
  23.         $i++;
  24.         print "$i. $thing\n";
  25.     }
  26.     print "Which one should I use? ";
  27.     chop($answer = <STDIN>);
  28.     $answer--;        # to get the index for the array
  29.     $sendmail = $maillocation[$answer];
  30. }
  31.  
  32. print "Sendmail is set to $sendmail\n";
  33.  
  34. print "Do you want to use PGP? [Yn] ";
  35. chop ($yesno = <STDIN>);
  36. if (($yesno eq 'Y') || ($yesno eq 'y') || ($yesno eq '')) {
  37.     print "OK, we're using PGP.\n";
  38.  
  39.     require "Html/data/pgp.dat";
  40.     if ($sc_use_pgp eq "yes") {
  41.         system("pgp -ka Html/data/public.pgp shopkeeper");        # must have the PGP text file here
  42.     } else {
  43.         print "Um, you need to configure your public key in the shop setup.\n";
  44.         print "I haven't added a key to the keyring - PGP will not work til you do that.\n";
  45.     }
  46.     $pgplocation = `whereis pgp`;
  47.     $pgplocation =~ s/$pgp://;
  48.     $pgplocation =~ s/\S+\.\S+//;
  49.     @pgplocation = split(/\s+/, $pgplocation);
  50.  
  51.     if (!@pgplocation) {
  52.         print "Can't find pgp. Aborting.\n";
  53.         print "You can't install this without PGP installed on the system.\n";
  54.         print "Run the configure script again and choose No when asked if you want PGP.\n";
  55.         exit;
  56.     } elsif (scalar(@pgplocation) == 1) {
  57.         $pgp = $pgplocation[0];
  58.     } else {
  59.     print "I found more than one instance of pgp:\n";
  60.         $i = 0;
  61.         foreach $thing (@pgplocation) {
  62.             $i++;
  63.             print "$i. $thing\n";
  64.         }
  65.         print "Which one should I use? ";
  66.         chop($answer = <STDIN>);
  67.         $answer--;        # to get the index for the array
  68.         $pgp = $pgplocation[$answer];
  69.     }
  70.  
  71.     if ($ENV{'PGPPATH'}) {
  72.         $pgppathlocation = $ENV{'PGPPATH'};
  73.         print "I've found your pgp path: $pgppathlocation\n";
  74.     } else {
  75.         print "What directory do you keep your PGP keyring in?\n";
  76.         print "(must start with / (absolute directory); leave blank for current directory)\n";
  77.         print "Keyring directory: ";
  78.         chop ($pgppathlocation = <STDIN>);
  79.     }
  80.     # add a check for user id here if you want to
  81. } else {
  82.     print "We won't use PGP.\n";
  83. }
  84.  
  85. chop($pwd = `pwd`);
  86. $basehtml = "$pwd/Html/Products";
  87. print "Base HTML directory is set to $basehtml\n";
  88.  
  89. print "What is the base URL for your shop (eg http://www.company.com/MyShop/): ";
  90. chop($baseurl = <STDIN>);
  91. $baseurl =~ s/\/$//;    # standardize to no slash on end
  92. $baseurl .= "/Html/Products";
  93.  
  94. open (CONFIGDATA, ">Html/data/configure.dat") || die "Can't open Html/data/configure.dat to write configurations: $!";
  95. print CONFIGDATA <<"EOF";
  96.  
  97. # Data created by configure script
  98. # Edit with care!
  99.  
  100. \$mailprog             = "$sendmail";
  101. \$sc_root_web_path     = "$basehtml";
  102. \$sc_server_url         = "$baseurl";
  103. \$pgp_path             = ("$pgplocation");
  104. \$pgp_config_files     = ("$pgppathlocation");
  105.  
  106. EOF
  107. close CONFIGDATA;
  108.  
  109. print "Finished configuring your shop.\n";
  110. print "Untarring webstore library files...\n";
  111.  
  112. system ("gzip -d webstore.tar.gz"); #|| die "Couldn't unzip webstore.tar.gz: $!";
  113. system ("tar -xvf webstore.tar"); #|| die "Couldn't untar webstore.tar: $!";
  114. chmod (0755, "web_store.cgi", "sendemail.cgi", "Library/*.pl", "Library/*.cgi", "Library/*.javascript") || die "Couldn't chmod untarred files: $!";
  115. mkdir ("Admin_files", 0755) || die "Couldn't make directory Admin_files: $!";
  116. mkdir ("User_carts", 0755) || die "Couldn't make directory Admin_files: $!";